import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
import torchvision.transforms as transforms
from torchsummary import summary
from torchviz import make_dot
from models.Resnet import ResNet18, ResNet
from models.Fcanet import make_Fcanet
from models.source_fcanet import fcanet34
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

# 创建模型
model = make_Fcanet().to(device)

# 打印模型结构
summary(model, (3, 32, 32))

# 可视化网络结构
x = torch.randn(1, 3, 32, 32).to(device)
y = model(x)

dot = make_dot(y, params=dict(model.named_parameters()))
print(model)
# 手动保存图像
dot.save('./results/make_Fcanet.dot')  # 保存为.dot文件
dot.render('./results/make_Fcanet', format='png')  # 渲染为PNG图像